/**
 * FileName: FileEncryptTask.java
 * @Description: TODO(用一句话描述该文件做什么)
 * All rights Reserved, Designed By 21winmess
 * Copyright: Copyright(C) 2010-2011 
 * Company 21winmess DaLian LTD.
 * @author: Matrix xu
 * @version V2.0
 * Createdate: 2012-11-28 下午5:44:19
 *
 * Modification History:
 * Date Author Version Discription
 * -----------------------------------------------------------------------------------
 * 2012-11-28 Qute_Android2.0
 * Why & What is modified: <修改原因描述>
 */
package com.me.safebox.service;

import java.util.concurrent.Callable;

import com.me.safebox.utils.EncryptWorker;
import com.me.safebox.utils.FileHelper;

/**
 * @ClassName: FileEncryptTask
 * @Description:文件加密任务
 * @author: Matrix
 * @date: 2012-11-28 下午5:44:19
 * 
 */
public class FileEncryptTask implements Callable<IFuture> {
	private final static String TAG = "FileEncryptTask";

	private String fileAbsPath = null;

	private int fileType = FileConfig.FILE_TYPE_IMAGE;

	public FileEncryptTask(String fileAbsPath, int fileType) {
		this.fileAbsPath = fileAbsPath;
		this.fileType = fileType;
	}

	@Override
	public EncryFuture call() throws Exception {
		String[] array = FileHelper.getFileName(fileAbsPath);//获得文件名
		String desPath = FileHelper.moveFile(fileAbsPath, fileType);//移动文件
		byte[] resultForHead = EncryptWorker.encryptFile(desPath);//加密
		EncryFuture encryFuture = new EncryFuture();
		encryFuture.folderId = 0;
		encryFuture.sourceDir = array[1];//获得源文件所在目录
		encryFuture.desPath = desPath;
		encryFuture.sourceName = array[0];//获得文件名称
		if (desPath != null) {
			encryFuture.encryResult = true;
		} else {
			encryFuture.encryResult = false;
		}
		return encryFuture;
	}
}
